<?php
require_once 'Usuario.php';
date_default_timezone_set('America/Santiago');
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Fecha en el pasado
require_once("conf/_funciones.php");
if ($_GET["logout"]) {
    session_name($nombre_sesion);
    session_start();
    session_unset();
    session_destroy();
}

if($_POST["user"] != "" && $_POST["pass"] != "") {
    $nickN = $_POST["user"];
    $passN = $_POST["pass"];
    session_name($nombre_sesion);
    session_start();
    if ($_SESSION['tmptxt'] == $_POST['captcha']) {
        $usuario = new Usuario();
        $a = $usuario->login($nickN, $passN);
        if ($a == 0) {
            $_SESSION["Nick"] = $nickN;
            $_SESSION["Tiempo"] = time()+$tiempo_exc;
            $_SESSION["Poder"] = $usuario->getPrivilegio();
            redirige("index.php");
        }
        else {
            echo "Error Numero $a";
        }
    }
    else
        echo "Error en Captcha";

}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>GestionDVD - Login</title>
<link rel="shortcut icon" href="icono.ico" />
<link href="css/estilo.css" rel="stylesheet" type="text/css" />
<link href="css/facebox.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="scripts/scripts.js"></script>
<script type="text/javascript" src="scripts/ultimo.js"></script>
</head>

<body>
<div id="mainContainer">
<?php require("conf/menu.html"); ?>
<p>&nbsp;</p>


              <form id="form" name="form" method="post" action="login.php">
			<?  if ($errorL == 4) { echo '<table width="301" border="0" align="center"><tr><td width="295"><div class="error" align="center">ERROR!! Contraseña Invalida!</div></td></tr></table>'; }
                            if ($errorL == 6) { echo '<table width="301" border="0" align="center"><tr><td width="295"><div class="error" align="center">ERROR!! Usuario no existe!</div></td></tr></table>'; }
			    if (!$errorL) { echo '<table width="301" border="0" align="center"><tr><td width="295"><div class="info" align="center">Debe indentficarse para accceder</div></td></tr></table>'; } ?>
                <table width="200" border="0" align="center">
                <tr>
                  <td colspan="2"><div align="center"><b>Identificate</b></div></td>
                </tr>
                <tr>
                  <td>Usuario</td>
                  <td><input name="user" type="text" id="user" size="15" maxlength="15" /></td>
                </tr>
                <tr>
                  <td>Contraseña</td>
                  <td><input name="pass" type="password" id="pass" size="15" maxlength="15" /></td>
                </tr>
                <tr>
                  <td><img id="argazki" src="captcha.gif" width="100" height="30" vspace="3" /></td>
                  <td><input name="captcha" type="text" id="captcha" size="8" />
                  <a href="javascript:ci('argazki');"><img src="images/images.jpg" width="15" border="0" height="15" alt="Recargar Captcha" /></a></td>
                </tr>
                <tr>
                  <td colspan="2" align="center"><input type="submit" name="button" id="button" value="Enviar" /></td>
                </tr>
                <tr>
                  <td colspan="2" align="center">&nbsp;</td>
                </tr>
                <tr>
                  <td colspan="2" align="center">&nbsp;</td>
                </tr>
                <tr>
                    <td colspan="2" align="center"><a href="registro.php">Registrate!</a></td>
                </tr>
                </table>
			    <p>&nbsp;</p>
              </form>
              <!--
               	<div class="info">Info message</div>
                <div class="success">Successful operation message</div>
                <div class="warning">Warning message</div>
                <div class="error">Error message</div> -->
                <?php //$sys->getFooter(); ?>
</div>
</body>
</html>